/** 
 * File-Name:ArticleDao.java
 *
 * Created on 2011-6-2 下午03:45:50
 * 
 * @author: Neo (neolimeng@gmail.com)
 * Software Engineering Institute, Peking University, China
 * 
 * Copyright (c) 2009, Peking University
 * 
 *
 */
package site.dao;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Date;

import neoutil.CommonDao;
import site.entity.Article;

/**
 * Description:
 * 
 * @author: Neo (neolimeng@gmail.com) Software Engineering Institute, Peking
 *          University, China
 * @version 1.0 2011-6-2 下午03:45:50
 */
public class ArticleDao extends CommonDao<Article, Long>{

	public ArticleDao(Connection connection) {
		super(Article.class, connection);
	}

	public void save(Article article) throws SQLException {
		Object[] params = { article.getUuid(), article.getTitle(),
				article.getContent(), article.getImagePath(),
				article.getFilePath(), article.getAuthorId(), article.getCid(),
				article.getCategoryId(), new Date(),article.getUpdateDate(),
				article.getStatus(), article.getEntityStatus() };
		execute(SQLString.SQL_ARTICLE_INSERT, params);
	}

	public void update(Article article) throws SQLException {
		Object[] params = { article.getUuid(), article.getTitle(),
				article.getContent(), article.getImagePath(),
				article.getFilePath(), article.getAuthorId(), article.getCid(),
				article.getCategoryId(), article.getUpdateDate(), article.getStatus(),
				article.getEntityStatus(), article.getId() };
		execute(SQLString.SQL_ARTICLE_UPDATE, params);
	}
	
	public void delete(Article article) throws SQLException {
		article.setEntityStatus(0);
		update(article);
	}
}
